﻿
@{
    ViewBag.Title = "PEMainlyView";
    Layout = "~/Views/Shared/_MyLayout.cshtml";

}

@*主业前期测算——结算*@

<style>
    .layui-table-cell {
        height: 20px;
        line-height: 20px;
    }
</style>
<table id="table1" lay-filter="demo">
    <thead>
        <tr>
            <th lay-data="{field:'A1',title:'A1', width:130,align:'center'}"></th>
            <th lay-data="{field:'A2',title:'A2', width:150,align:'center'}"></th>
            <th lay-data="{field:'A3',title:'A3', width:150,align:'center'}"></th>
            <th lay-data="{field:'A4',title:'A4', width:150,align:'center'}"></th>
            <th lay-data="{field:'A5',title:'A5', width:150,align:'center'}"></th>
            <th lay-data="{field:'A6',title:'A6', width:250,align:'center'}"></th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>计划资金核算</td>
        </tr>
        <tr>
            <td>费用名称</td>
            <td>设计概算（元）</td>
            <td>预计结算（元）</td>
            <td>差额</td>
            <td>取费公式</td>
            <td>备注</td>
        </tr>
        <tr>
            <td>投资总额</td>
        </tr>
        <tr>
            <td>设计费</td>
        </tr>
        <tr>
            <td>监理费</td>
        </tr>
        <tr>
            <td>甲供材料</td>
        </tr>
        <tr>
            <td>甲供设备</td>
        </tr>
        <tr>
            <td>土建工程施工费</td>
        </tr>
        <tr>
            <td>安装工程施工费</td>
        </tr>
        <tr>
            <td>主材（红泥管）</td>
        </tr>
        <tr>
            <td>实验调试费</td>
        </tr>
        <tr>
            <td>表计施工费</td>
        </tr>
        <tr>
            <td>赔偿费</td>
        </tr>
        <tr>
            <td>成本核算</td>
        </tr>
        <tr>
            <td>费用名称</td>
            <td>预计结算（元）</td>
            <td>成本测算（元）</td>
            <td>差额（元）</td>
            <td></td>
            <td>备注</td>
        </tr>
        <tr>
            <td>土建施工费</td>
        </tr>
        <tr>
            <td>安装施工费</td>
        </tr>
        <tr>
            <td>主材（红泥管）</td>
        </tr>
        <tr>
            <td>实验调试费</td>
        </tr>
        <tr>
            <td>表计施工费</td>
        </tr>
        <tr>
            <td>赔偿费</td>
        </tr>
        <tr>
            <td>协调费</td>
        </tr>
        <tr>
            <td>税金</td>
        </tr>
        <tr>
            <td>公司管理费</td>
        </tr>
        <tr>
            <td>合计</td>
        </tr>
        <tr>
            <td>毛利润合计</td>
        </tr>

    </tbody>
</table>
<script type="text/javascript">
    var PreEstId = parent.$("#PreEstId").val();
    var PreEstType = parent.$("#ProjectType").val();
    var DataMap =  @Html.Raw(Json.Encode(ViewBag.DataMap));
    var table;
    layui.use(['form', 'table', 'upload', 'layer', 'element'], function () {
        var element = layui.element;
        var form = layui.form;
        table = layui.table;
        var tab = parent.tab;
        var layer = layui.layer;



        table.init('demo', {
            limit: 100,
            done: function (res, curr, count) {
                tableInit();
            }

        });

        table.on('edit(demo)', function (obj) { //注：edit是固定事件名，test是table原始容器的属性 lay-filter="对应的值"
            //console.log(obj.value); //得到修改后的值
            //console.log(obj.field); //当前编辑的字段名
            //console.log(obj.data); //所在行的所有相关数据

            var temp = obj;
            var RowIndex = obj.tr[0].rowIndex;
            var FieldName, FieldValue;
            switch (RowIndex) {
                case 2:
                    if (obj.field == "A2") {
                        FieldName = "TZZE";
                    }
                    break;
                case 3:
                    if (obj.field == "A5") {
                        FieldName = "SJF_F";
                        try {
                            eval(obj.value);
                            FieldValue = obj.value;
                            UpdateTable(FieldName, FieldValue, PreEstId);
                            if (DataMap.result == "OK") {
                                var tempnum = eval(DataMap.SJF_F);
                                var tempSum = (DataMap.MeterialFee + DataMap.JHTJSGF + DataMap.JHAZSGF + DataMap.JHSYF) * tempnum;
                                obj.value = tempSum;
                                FieldName = "SJF";
                            }
                            else {
                                layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                                table.reload("table1");
                            }
                        } catch (e) {
                            layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                            table.reload("table1");
                            return;
                        }
                    }
                    else if (obj.field == "A6") {
                        FieldName = "Memo_SJF";
                    }
                    break;
                case 4:
                    if (obj.field == "A5") {
                        FieldName = "JLF_F";
                        try {
                            eval(obj.value);
                            FieldValue = obj.value;
                            UpdateTable(FieldName, FieldValue, PreEstId);
                            if (DataMap.result == "OK") {
                                var tempnum = eval(DataMap.JLF_F);
                                var tempSum = (DataMap.MeterialFee + DataMap.JHTJSGF + DataMap.JHAZSGF + DataMap.JHSYF) * tempnum;
                                obj.value = tempSum;
                                FieldName = "JLF";
                            }
                            else {
                                layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                                table.reload("table1");
                            }
                        } catch (e) {
                            layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                            table.reload("table1");
                            return;
                        }
                    }
                    else if (obj.field == "A6") {
                        FieldName = "Memo_JLF";
                    }
                    break;
                case 5:
                    if (obj.field == "A6") {
                        FieldName = "Memo_JGCL";
                    }
                    break;
                case 6:
                    if (obj.field == "A6") {
                        FieldName = "Memo_JGSB";
                    }
                    break;
                case 7:
                    if (obj.field == "A5") {
                        FieldName = "JHTJSGF_F";
                        try {
                            eval(obj.value);
                            FieldValue = obj.value;
                            UpdateTable(FieldName, FieldValue, PreEstId);
                            if (DataMap.result == "OK") {
                                var tempSum = eval(obj.value);
                                obj.value = tempSum;
                                FieldName = "JHTJSGF";
                            }
                            else {
                                layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                                table.reload("table1");
                            }
                        } catch (e) {
                            layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                            table.reload("table1");
                            return;
                        }
                    }
                    else if (obj.field == "A6") {
                        FieldName = "Memo_JHTJSGF";
                    }
                    break;
                case 8:
                    if (obj.field == "A5") {
                        FieldName = "JHAZSGF_F";
                        try {
                            eval(obj.value);
                            FieldValue = obj.value;
                            UpdateTable(FieldName, FieldValue, PreEstId);
                            if (DataMap.result == "OK") {
                                var tempSum = eval(obj.value);
                                obj.value = tempSum;
                                FieldName = "JHAZSGF";
                            }
                            else {
                                layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                                table.reload("table1");
                            }
                        } catch (e) {
                            layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                            table.reload("table1");
                            return;
                        }
                    }
                    else if (obj.field == "A6") {
                        FieldName = "Memo_JHAZSGF";
                    }
                    break;
                case 9:
                    if (obj.field == "A5") {
                        FieldName = "JHZC_F";
                        try {
                            eval(obj.value);
                            FieldValue = obj.value;
                            UpdateTable(FieldName, FieldValue, PreEstId);
                            if (DataMap.result == "OK") {
                                var tempSum = eval(obj.value);
                                obj.value = tempSum;
                                FieldName = "JHZC";
                            }
                            else {
                                layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                                table.reload("table1");
                            }
                        } catch (e) {
                            layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                            table.reload("table1");
                            return;
                        }
                    }
                    else if (obj.field == "A6") {
                        FieldName = "Memo_JHZC";
                    }
                    break;
                case 10:
                    if (obj.field == "A5") {
                        FieldName = "JHSYF_F";
                        try {
                            eval(obj.value);
                            FieldValue = obj.value;
                            UpdateTable(FieldName, FieldValue, PreEstId);
                            if (DataMap.result == "OK") {
                                var tempSum = eval(obj.value);
                                obj.value = tempSum;
                                FieldName = "JHSYF";
                            }
                            else {
                                layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                                table.reload("table1");
                            }
                        } catch (e) {
                            layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                            table.reload("table1");
                            return;
                        }
                    }
                    else if (obj.field == "A6") {
                        FieldName = "Memo_JHSYF";
                    }
                    break;
                case 11:
                    if (obj.field == "A5") {
                        FieldName = "JHBJSGF_F";
                        try {
                            eval(obj.value);
                            FieldValue = obj.value;
                            UpdateTable(FieldName, FieldValue, PreEstId);
                            if (DataMap.result == "OK") {
                                var tempSum = eval(obj.value);
                                obj.value = tempSum;
                                FieldName = "JHBJSGF";
                            }
                            else {
                                layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                                table.reload("table1");
                            }
                        } catch (e) {
                            layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                            table.reload("table1");
                            return;
                        }
                    }
                    else if (obj.field == "A6") {
                        FieldName = "Memo_JHBJSGF";
                    }
                    break;
                case 12:
                    if (obj.field == "A5") {
                        FieldName = "JHPCF_F";
                        try {
                            eval(obj.value);
                            FieldValue = obj.value;
                            UpdateTable(FieldName, FieldValue, PreEstId);
                            if (DataMap.result == "OK") {
                                var tempSum = eval(obj.value);
                                obj.value = tempSum;
                                FieldName = "JHPCF";
                            }
                            else {
                                layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                                table.reload("table1");
                            }
                        } catch (e) {
                            layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                            table.reload("table1");
                            return;
                        }
                    }
                    else if (obj.field == "A6") {
                        FieldName = "Memo_JHPCF";
                    }
                    break;
                case 15:
                    if (obj.field == "A6") {
                        FieldName = "Memo_CBTJSGF";
                    }
                    break;
                case 16:
                    if (obj.field == "A6") {
                        FieldName = "Memo_CBAZSGF";
                    }
                    break;
                case 17:
                    if (obj.field == "A3") {
                        FieldName = "CBZC";
                        try {
                            eval(obj.value);
                            
                        } catch (e) {
                            layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                            table.reload("table1");
                            return;
                        }
                    }
                    else if (obj.field == "A6") {
                        FieldName = "Memo_CBZC";
                    }
                    break;
                case 18:
                    if (obj.field == "A6") {
                        FieldName = "Memo_CBSYF";
                    }
                    break;
                case 19:
                    if (obj.field == "A3") {
                        FieldName = "CBBJSGF";
                        try {
                            eval(obj.value);

                        } catch (e) {
                            layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                            table.reload("table1");
                            return;
                        }
                    }
                    else if (obj.field == "A6") {
                        FieldName = "Memo_CBBJSGF";
                    }
                    break;
                case 20:
                    if (obj.field == "A3") {
                        FieldName = "CBPCF";
                        try {
                            eval(obj.value);

                        } catch (e) {
                            layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                            table.reload("table1");
                            return;
                        }
                    }
                    else if (obj.field == "A6") {
                        FieldName = "Memo_CBPCF";
                    }
                    break;
                case 21:
                    if (obj.field == "A6") {
                        FieldName = "Memo_CBXTF";
                    }
                    break;
                case 22:
                    if (obj.field == "A3") {
                        FieldName = "CBSJ";
                        try {
                            eval(obj.value);

                        } catch (e) {
                            layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                            table.reload("table1");
                            return;
                        }
                    }
                    else if (obj.field == "A6") {
                        FieldName = "Memo_CBSJ";
                    }
                    break;
                case 23:
                    if (obj.field == "A3") {
                        FieldName = "CBGSGLF";
                        try {
                            eval(obj.value);

                        } catch (e) {
                            layer.msg('数据填写格式有误', { icon: 2, time: 1500 });
                            table.reload("table1");
                            return;
                        }
                    }
                    else if (obj.field == "A6") {
                        FieldName = "Memo_CBGSGLF";
                    }
                    break;
                case 24:
                    if (obj.field == "A6") {
                        FieldName = "Memo_HJ";
                    }
                    break;

            }

            FieldValue = obj.value;
            UpdateTable(FieldName, FieldValue, PreEstId);






        });



    });
    

    function tableInit() {
        var temp1 = $(".layui-table-body tbody").find("tr[data-index='0']");
        //整理第0行元素
        $(temp1).find("td[data-field!='A1']").remove();
        $(temp1).find("td[data-field='A1']").attr("colspan", "6");
        $(temp1).find("td[data-field='A1'] div").removeClass("laytable-cell-1-0-0");

        //第2行数据整理
        temp1 = $(".layui-table-body tbody").find("tr[data-index='2']");
        $(temp1).find("td[data-field='A2']").attr("data-edit", "text");
        $(temp1).find("td[data-field='A2'] div").text(DataMap.TZZE);

        //第3行数据整理  设计费（甲供材料+土建施工+安装工程+试验调试费）*费率
        temp1 = $(".layui-table-body tbody").find("tr[data-index='3']");
        $(temp1).find("td[data-field='A5']").attr("data-edit", "text");
        $(temp1).find("td[data-field='A6']").attr("data-edit", "text");
        if (DataMap.SJF == null || DataMap.SJF == "") {
            DataMap.SJF = 0;
        }


        $(temp1).find("td[data-field='A3'] div").text(DataMap.SJF);
        $(temp1).find("td[data-field='A5'] div").text(DataMap.SJF_F);
        $(temp1).find("td[data-field='A6'] div").text(DataMap.Memo_SJF);



        //第4行数据整理  监理费（甲供材料+土建施工+安装工程+试验调试费）*费率
        temp1 = $(".layui-table-body tbody").find("tr[data-index='4']");
        $(temp1).find("td[data-field='A5']").attr("data-edit", "text");
        $(temp1).find("td[data-field='A6']").attr("data-edit", "text");
        $(temp1).find("td[data-field='A3'] div").text(DataMap.JLF);
        $(temp1).find("td[data-field='A5'] div").text(DataMap.JLF_F);
        $(temp1).find("td[data-field='A6'] div").text(DataMap.Memo_JLF);

        //第5行数据整理  甲供材料
        temp1 = $(".layui-table-body tbody").find("tr[data-index='5']");
        $(temp1).find("td[data-field='A6']").attr("data-edit", "text");
        if (DataMap.MeterialFee == null || DataMap.MeterialFee == "") DataMap.MeterialFee = 0;
        $(temp1).find("td[data-field='A3'] div").text((DataMap.MeterialFee).toFixed(2));
        $(temp1).find("td[data-field='A6'] div").text(DataMap.Memo_JGCL);

        //第6行数据整理  甲供设备
        temp1 = $(".layui-table-body tbody").find("tr[data-index='6']");
        $(temp1).find("td[data-field='A6']").attr("data-edit", "text");
        if (DataMap.EquipFee == null || DataMap.EquipFee == "") DataMap.EquipFee = 0;
        $(temp1).find("td[data-field='A3'] div").text((DataMap.EquipFee).toFixed(2));
        $(temp1).find("td[data-field='A6'] div").text(DataMap.Memo_JGSB);

        //第7行数据整理  计划土建施工费
        temp1 = $(".layui-table-body tbody").find("tr[data-index='7']");
        $(temp1).find("td[data-field='A6']").attr("data-edit", "text");
        $(temp1).find("td[data-field='A5']").attr("data-edit", "text");
        if (DataMap.JHTJSGF == null || DataMap.JHTJSGF == "") DataMap.JHTJSGF = 0;
        $(temp1).find("td[data-field='A3'] div").text((DataMap.JHTJSGF).toFixed(2));
        $(temp1).find("td[data-field='A5'] div").text(DataMap.JHTJSGF_F);
        $(temp1).find("td[data-field='A6'] div").text(DataMap.Memo_JHTJSGF);

        //第8行数据整理  计划安装施工费
        temp1 = $(".layui-table-body tbody").find("tr[data-index='8']");
        $(temp1).find("td[data-field='A6']").attr("data-edit", "text");
        $(temp1).find("td[data-field='A5']").attr("data-edit", "text");
        if (DataMap.JHAZSGF == null || DataMap.JHAZSGF == "") DataMap.JHAZSGF = 0;
        $(temp1).find("td[data-field='A3'] div").text((DataMap.JHAZSGF).toFixed(2));
        $(temp1).find("td[data-field='A5'] div").text(DataMap.JHAZSGF_F);
        $(temp1).find("td[data-field='A6'] div").text(DataMap.Memo_JHAZSGF);

        //第9行数据整理  计划主材
        temp1 = $(".layui-table-body tbody").find("tr[data-index='9']");
        $(temp1).find("td[data-field='A6']").attr("data-edit", "text");
        $(temp1).find("td[data-field='A5']").attr("data-edit", "text");
        if (DataMap.JHZC == null || DataMap.JHZC == "") DataMap.JHZC = 0;
        $(temp1).find("td[data-field='A3'] div").text((DataMap.JHZC).toFixed(2));
        $(temp1).find("td[data-field='A5'] div").text(DataMap.JHZC_F);
        $(temp1).find("td[data-field='A6'] div").text(DataMap.Memo_JHZC);

        //第10行数据整理  计划试验费
        temp1 = $(".layui-table-body tbody").find("tr[data-index='10']");
        $(temp1).find("td[data-field='A6']").attr("data-edit", "text");
        $(temp1).find("td[data-field='A5']").attr("data-edit", "text");
        if (DataMap.JHSYF == null || DataMap.JHSYF == "") DataMap.JHSYF = 0;
        $(temp1).find("td[data-field='A3'] div").text((DataMap.JHSYF).toFixed(2));
        $(temp1).find("td[data-field='A5'] div").text(DataMap.JHSYF_F);
        $(temp1).find("td[data-field='A6'] div").text(DataMap.Memo_JHSYF);

        //第11行数据整理  表计施工费
        temp1 = $(".layui-table-body tbody").find("tr[data-index='11']");
        $(temp1).find("td[data-field='A6']").attr("data-edit", "text");
        $(temp1).find("td[data-field='A5']").attr("data-edit", "text");
        if (DataMap.JHBJSGF == null || DataMap.JHBJSGF == "") DataMap.JHBJSGF = 0;
        $(temp1).find("td[data-field='A3'] div").text((DataMap.JHBJSGF).toFixed(2));
        $(temp1).find("td[data-field='A5'] div").text(DataMap.JHBJSGF_F);
        $(temp1).find("td[data-field='A6'] div").text(DataMap.Memo_JHBJSGF);

        //第12行数据整理  表计施工费
        temp1 = $(".layui-table-body tbody").find("tr[data-index='12']");
        $(temp1).find("td[data-field='A6']").attr("data-edit", "text");
        $(temp1).find("td[data-field='A5']").attr("data-edit", "text");
        if (DataMap.JHPCF == null || DataMap.JHPCF == "") DataMap.JHPCF = 0;
        $(temp1).find("td[data-field='A3'] div").text((DataMap.JHPCF).toFixed(2));
        $(temp1).find("td[data-field='A5'] div").text(DataMap.JHPCF_F);
        $(temp1).find("td[data-field='A6'] div").text(DataMap.Memo_JHPCF);

        //第13行数据整理  成本核算-表头
        temp1 = $(".layui-table-body tbody").find("tr[data-index='13']");
        $(temp1).find("td[data-field!='A1']").remove();
        $(temp1).find("td[data-field='A1']").attr("colspan", "6");
        $(temp1).find("td[data-field='A1'] div").removeClass("laytable-cell-1-0-0");

        //////////////////////////////////////////////////////////////////////////////

        //第15行数据整理  成本土建施工费
        temp1 = $(".layui-table-body tbody").find("tr[data-index='15']");
        $(temp1).find("td[data-field='A6']").attr("data-edit", "text");
        if (DataMap.CivilPrice == null || DataMap.CivilPrice == "") {
            DataMap.CivilPrice = 0;
        } 
        $(temp1).find("td[data-field='A3'] div").text((DataMap.CivilPrice).toFixed(2));
        $(temp1).find("td[data-field='A6'] div").text(DataMap.Memo_CBTJSGF);

        $(temp1).find("td[data-field='A2'] div").text((DataMap.JHTJSGF).toFixed(2));
        $(temp1).find("td[data-field='A4'] div").text((DataMap.JHTJSGF - DataMap.CivilPrice).toFixed(2));

        //第16行数据整理  成本安装施工费
        temp1 = $(".layui-table-body tbody").find("tr[data-index='16']");
        $(temp1).find("td[data-field='A6']").attr("data-edit", "text");
        if (DataMap.InstallFee == null || DataMap.InstallFee == "") {
            DataMap.InstallFee = 0;
        }
        $(temp1).find("td[data-field='A3'] div").text((DataMap.InstallFee).toFixed(2));
        $(temp1).find("td[data-field='A6'] div").text(DataMap.Memo_CBAZSGF);

        $(temp1).find("td[data-field='A2'] div").text((DataMap.JHAZSGF).toFixed(2));
        $(temp1).find("td[data-field='A4'] div").text((DataMap.JHAZSGF - DataMap.InstallFee).toFixed(2));

        //第17行数据整理  成本主材
        temp1 = $(".layui-table-body tbody").find("tr[data-index='17']");
        $(temp1).find("td[data-field='A6']").attr("data-edit", "text");
        $(temp1).find("td[data-field='A3']").attr("data-edit", "text");
        if (DataMap.CBZC == null || DataMap.CBZC == "") {
            DataMap.CBZC = 0;
        }
        $(temp1).find("td[data-field='A3'] div").text((DataMap.CBZC).toFixed(2));
        $(temp1).find("td[data-field='A6'] div").text(DataMap.Memo_CBZC);

        $(temp1).find("td[data-field='A2'] div").text((DataMap.JHZC).toFixed(2));
        $(temp1).find("td[data-field='A4'] div").text((DataMap.JHZC - DataMap.CBZC).toFixed(2));

        //第18行数据整理  成本试验费
        temp1 = $(".layui-table-body tbody").find("tr[data-index='18']");
        $(temp1).find("td[data-field='A6']").attr("data-edit", "text");
        if (DataMap.TestFee == null || DataMap.TestFee == "") {
            DataMap.TestFee = 0;
        }
        $(temp1).find("td[data-field='A3'] div").text((DataMap.TestFee).toFixed(2));
        $(temp1).find("td[data-field='A6'] div").text(DataMap.Memo_CBSYF);

        $(temp1).find("td[data-field='A2'] div").text((DataMap.JHSYF).toFixed(2));
        $(temp1).find("td[data-field='A4'] div").text((DataMap.JHSYF - DataMap.TestFee).toFixed(2));

        //第19行数据整理  成本表计施工费
        temp1 = $(".layui-table-body tbody").find("tr[data-index='19']");
        $(temp1).find("td[data-field='A6']").attr("data-edit", "text");
        $(temp1).find("td[data-field='A3']").attr("data-edit", "text");
        if (DataMap.CBBJSGF == null || DataMap.CBBJSGF == "") {
            DataMap.CBBJSGF = 0;
        }
        $(temp1).find("td[data-field='A3'] div").text((DataMap.CBBJSGF).toFixed(2));
        $(temp1).find("td[data-field='A6'] div").text(DataMap.Memo_CBBJSGF);

        $(temp1).find("td[data-field='A2'] div").text((DataMap.JHBJSGF).toFixed(2));
        $(temp1).find("td[data-field='A4'] div").text((DataMap.JHBJSGF - DataMap.CBBJSGF).toFixed(2));

        //第20行数据整理  成本赔偿费
        temp1 = $(".layui-table-body tbody").find("tr[data-index='20']");
        $(temp1).find("td[data-field='A6']").attr("data-edit", "text");
        $(temp1).find("td[data-field='A3']").attr("data-edit", "text");
        if (DataMap.CBPCF == null || DataMap.CBPCF == "") {
            DataMap.CBPCF = 0;
        }
        $(temp1).find("td[data-field='A3'] div").text((DataMap.CBPCF).toFixed(2));
        $(temp1).find("td[data-field='A6'] div").text(DataMap.Memo_CBPCF);

        $(temp1).find("td[data-field='A2'] div").text((DataMap.JHPCF).toFixed(2));
        $(temp1).find("td[data-field='A4'] div").text((DataMap.JHPCF - DataMap.CBPCF).toFixed(2));

        //第21行数据整理  成本协调费
        temp1 = $(".layui-table-body tbody").find("tr[data-index='21']");
        $(temp1).find("td[data-field='A6']").attr("data-edit", "text");
        if (DataMap.CoordFee == null || DataMap.CoordFee == "") {
            DataMap.CoordFee = 0;
        }
        $(temp1).find("td[data-field='A3'] div").text((DataMap.CoordFee).toFixed(2));
        $(temp1).find("td[data-field='A6'] div").text(DataMap.Memo_CBXTF);

        $(temp1).find("td[data-field='A4'] div").text((0 - DataMap.CoordFee).toFixed(2));

        //第22行数据整理  成本税金
        temp1 = $(".layui-table-body tbody").find("tr[data-index='22']");
        $(temp1).find("td[data-field='A6']").attr("data-edit", "text");
        $(temp1).find("td[data-field='A3']").attr("data-edit", "text");
        if (DataMap.CBSJ == null || DataMap.CBSJ == "") {
            DataMap.CBSJ = 0;
        }
        $(temp1).find("td[data-field='A3'] div").text((DataMap.CBSJ).toFixed(2));
        $(temp1).find("td[data-field='A6'] div").text(DataMap.Memo_CBSJ);
        $(temp1).find("td[data-field='A4'] div").text((0 - DataMap.CBSJ).toFixed(2));

        //第23行数据整理  成本公司管理费
        temp1 = $(".layui-table-body tbody").find("tr[data-index='23']");
        $(temp1).find("td[data-field='A6']").attr("data-edit", "text");
        $(temp1).find("td[data-field='A3']").attr("data-edit", "text");
        if (DataMap.CBGSGLF == null || DataMap.CBGSGLF == "") {
            DataMap.CBGSGLF = 0;
        }
        $(temp1).find("td[data-field='A3'] div").text((DataMap.CBGSGLF).toFixed(2));
        $(temp1).find("td[data-field='A6'] div").text(DataMap.Memo_CBGSGLF);
        $(temp1).find("td[data-field='A4'] div").text((0 - DataMap.CBGSGLF).toFixed(2));


        //刷新计划资金预计结算
        //设计费
        var tempnum = eval(DataMap.SJF_F);
        var tempSum = (DataMap.MeterialFee + DataMap.JHTJSGF + DataMap.JHAZSGF + DataMap.JHSYF) * tempnum;
        temp1 = $(".layui-table-body tbody").find("tr[data-index='3']");
        $(temp1).find("td[data-field='A3'] div").text(tempSum.toFixed(2));
        DataMap.SJF = tempSum;
        //监理费
        var tempnum = eval(DataMap.JLF_F);
        var tempSum = (DataMap.MeterialFee + DataMap.JHTJSGF + DataMap.JHAZSGF + DataMap.JHSYF) * tempnum;
        temp1 = $(".layui-table-body tbody").find("tr[data-index='4']");
        $(temp1).find("td[data-field='A3'] div").text(tempSum.toFixed(2));
        DataMap.JLF = tempSum;
        //投资总额
        tempSum = DataMap.SJF + DataMap.JLF + DataMap.MeterialFee + DataMap.EquipFee + DataMap.JHTJSGF +
            DataMap.JHAZSGF + DataMap.JHZC + DataMap.JHSYF + DataMap.JHBJSGF + DataMap.JHPCF;
        temp1 = $(".layui-table-body tbody").find("tr[data-index='2']");
        $(temp1).find("td[data-field='A3'] div").text(tempSum.toFixed(2));
        $(temp1).find("td[data-field='A4'] div").text((DataMap.TZZE - tempSum).toFixed(2));

        //合计行
        //第24行数据整理  合计
        temp1 = $(".layui-table-body tbody").find("tr[data-index='24']");
        tempSum = DataMap.JHTJSGF + DataMap.JHAZSGF + DataMap.JHZC + DataMap.JHSYF + DataMap.JHBJSGF + DataMap.JHPCF;
        $(temp1).find("td[data-field='A2'] div").text(tempSum.toFixed(2));

        tempSum = DataMap.CivilPrice + DataMap.InstallFee + DataMap.CBZC + DataMap.TestFee + DataMap.CBBJSGF +
            DataMap.CBPCF + DataMap.CoordFee + DataMap.CBSJ + DataMap.CBGSGLF;
        $(temp1).find("td[data-field='A3'] div").text(tempSum.toFixed(2));

        tempSum = (DataMap.JHTJSGF + DataMap.JHAZSGF + DataMap.JHZC + DataMap.JHSYF + DataMap.JHBJSGF + DataMap.JHPCF) -
            (DataMap.CivilPrice + DataMap.InstallFee + DataMap.CBZC + DataMap.TestFee + DataMap.CBBJSGF +
                DataMap.CBPCF + DataMap.CoordFee + DataMap.CBSJ + DataMap.CBGSGLF);
        $(temp1).find("td[data-field='A4'] div").text(tempSum.toFixed(2));

        $(temp1).find("td[data-field='A6']").attr("data-edit", "text");
        $(temp1).find("td[data-field='A6'] div").text(DataMap.Memo_HJ);

        //第25行数据整理  毛利润
        temp1 = $(".layui-table-body tbody").find("tr[data-index='25']");
        $(temp1).find("td[data-field='A2']").remove();
        $(temp1).find("td[data-field='A3']").remove();
        $(temp1).find("td[data-field='A1']").attr("colspan", "3");
        $(temp1).find("td[data-field='A4'] div").text(tempSum.toFixed(2));
        tempSum = tempSum / (DataMap.JHTJSGF + DataMap.JHAZSGF + DataMap.JHZC + DataMap.JHSYF + DataMap.JHBJSGF + DataMap.JHPCF);
        $(temp1).find("td[data-field='A5'] div").text((tempSum * 100).toFixed(2)+"%");


    }


    function UpdateTable(FieldName, FieldValue, PreEstId) {

        $.ajax({
            type: "POST",
            url: "/Estimate/PEMainlyJSUpdate",
            async: false,
            data: { "FieldName": FieldName, "FieldValue": FieldValue, "PreEstId": PreEstId, "PreEstType": PreEstType },
            success: function (msg) {
                if (msg.result == "OK") {
                    parent.layer.msg('修改成功，请刷新', { icon: 6, time: 1000 });
                    DataMap = msg;
                    tableInit();
                } else {
                    alert(msg.result);
                }
            }
        });
    }


</script>



